<?php


namespace App\Controller\Admin;


use App\Controller\AbstractController;
use App\Request\Admin\TaskPushIndexRequest;
use App\Request\Admin\TaskPushRequest;
use App\Request\Admin\TaskPushTaskIndexRequest;
use App\Service\Admin\TaskPushService;
use Hyperf\Di\Annotation\Inject;

class TaskPushController extends AbstractController
{

    /**
     * @Inject()
     * @var TaskPushService
     */
    protected $taskPushService;

    /**
     * 商机-任务列表
     * @param TaskPushTaskIndexRequest $request
     * @return mixed|\Psr\Http\Message\ResponseInterface
     */
    public function taskIndex(TaskPushTaskIndexRequest $request)
    {
        $where = $request->validated();
        $index = $this->taskPushService->taskIndex($where);
        return $this->response->success($index);
    }

    /**
     * 商机-推送商机
     * @param TaskPushRequest $request
     * @return mixed|\Psr\Http\Message\ResponseInterface
     * @throws \Exception
     */
    public function push(TaskPushRequest $request)
    {
        $data = $request->validated();
        $this->taskPushService->push($data);
        return $this->response->success();
    }

    /**
     * 商机-推送历史
     * @param TaskPushIndexRequest $request
     * @return mixed|\Psr\Http\Message\ResponseInterface
     */
    public function index(TaskPushIndexRequest $request)
    {
        $where = $request->validated();
        $index = $this->taskPushService->index($where);
        return $this->response->success($index);
    }
}